﻿#region Using directives

using System;
using System.Xml;
using System.Drawing.Design;
using System.ComponentModel;
using MCMLXVII.BackEnd.Services.OrganizationChart.Messages;
using MCMLXVII.BackEnd.Services.OrganizationChart.Interfaces;
using MCMLXVII.Tools.OrganizationChart.SmartEditors;
using MCMLXVII.Core.Common;
#endregion

namespace MCMLXVII.Tools.OrganizationChart.MembersClasses
{
    public class MemberRole: MemberBase, iOrganizationTreeMemberAsMember 
    {
        private msgMembershipInfo _RoleMemberID;
        private msgMembershipInfo[] _MemberOf;

        public override ucSmartBaseEditor GetEditor(bool UseGridEditor)
        {
            if (UseGridEditor)
                return new ucSmartGridEditor(this, base._NodeID);
            else
                return new ucSmartRoleEditor(this, base._NodeID);
        }


        public MemberRole(): base()
        {         
        }

        public override void LoadMemberData(msgOrganizationMemberInfo memberInfo)
        {
            base.LoadMemberData(memberInfo);
            _RoleMemberID = memberInfo.RoleMemberID;
            _MemberOf = memberInfo.MemberOf;

        }

        public override msgOrganizationMemberInfo GetMemberData()
        {
            return new msgOrganizationMemberInfo(base._MemberID, base._Description, base._NodeID, base._MemberClass, base._ClassProperties.OuterXml, 0, "", "", "", _RoleMemberID, _MemberOf, base._UpdateSequence);
        }


        [Browsable(false)]
        public override string MemberClassName
        {
            get { return "Role"; }
        }


        [Browsable(false)]
        public override System.Drawing.Icon GetIcon()
        {
            return Properties.Resources.icoCargo;
        }

        [LocCategory("Misc"), LocDescription("Role_Description"), LocDisplayName("Role_DisplayName"), Editor(typeof(RoleMembershipEditor), typeof(UITypeEditor))]
        public msgMembershipInfo RoleMemberID
        {
            get
            {
                return _RoleMemberID ;
            }

            set
            {
                _RoleMemberID = value;
            }
        }



        [LocCategory("Misc"), LocDescription("MemberOf_Description"), LocDisplayName("MemberOf_DisplayName"), Editor(typeof(UserGroupMembershipEditor), typeof(UITypeEditor)), TypeConverter(typeof(CollectionConverter))]
        public msgMembershipInfo[] MemberOf
        {
            get
            {
                return _MemberOf ;
            }

            set
            {
                _MemberOf = value;
            }
        }

    }
}
